package com.mall.model.vo;

import cn.hutool.core.collection.CollUtil;
import com.mall.model.domain.UmsAdmin;
import com.mall.model.domain.UmsMenu;
import com.mall.model.domain.UmsRole;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author : xyiaao
 * @createDate : 2022/3/30 18:38
 */
@NoArgsConstructor
@Data
public class AdminInfoVo {

    /**
     * 角色名称
     */
    private List<String> roles;

    /**
     * 图标
     */
    private String icon;

    /**
     * 菜单列表
     */
    private List<UmsMenu> menus;

    /**
     * 用户名
     */
    private String username;


    public static AdminInfoVo init(UmsAdmin umsAdmin, UmsRole umsRole, List<UmsMenu> umsMenuList) {

        AdminInfoVo adminInfoVo = new AdminInfoVo();
        adminInfoVo.setRoles(CollUtil.list(false, umsRole.getName()));
        adminInfoVo.setIcon(umsAdmin.getIcon());
        adminInfoVo.setUsername(umsAdmin.getUsername());
        adminInfoVo.setMenus(umsMenuList);
        return adminInfoVo;
    }

}
